<?Lassoscript
// Last modified 4/17/09 by Eric Landmann

// FUNCTIONALITY
// Sections form

// CHANGE NOTES
// 4/17/09
// Version 1.0

// Debugging
// Var:'svDebug' = 'Y';

// Convert action_params
Include:($svLibsPath)'section_params.inc';

// If Edit page, get the record
If: (Response_Filepath) >> 'setup_editrecord.lasso';
	// If Process = Y, form was submit, so update the record
	// Otherwise, it is a new edit so get the record
	If: $vProcess != 'Y';
		// Get the record
		Var:'vSQLSearchSection'='SELECT *
			FROM ' $svSectionsTable ' WHERE Section_ID = "'($vSID)'" LIMIT 1';
		Inline: $IV_SearchSections, -SQL=$vSQLSearchSection;
			// If Found_Count is wrong, the wrong ID was passed, so dump out 2000 "No Record Found"	
			If: (Found_Count) == 0;
				Var:'vError' = '2000';
				Abort;
			/If;
			Var:'vSection_Title' = Field:'Section_Title';
			Var:'vRequest_Info' = Field:'Request_Info';
			Var:'vSection_Description' = Field:'Section_Description';
			Var:'vAllow' = Field:'Allow';
		/Inline;
	Else;
		// Update the record
		Inline: $IV_UpdateSections, 'Severity_ID' = $vSID;
			// If there is an error, dump out error 1012 "Update Failed"
			If: (Error_CurrentError) != 0;
				Var:'vError' = '1012';
			/If;
		/Inline;
	/If;
	
/If;

'<h2>Forum Record</h2>\r';

// Standard Error Table
If: (Var:'vError') != '';
	LI_ShowError3: -ErrNum=$vError, -Option=$vOption;
/If;
?>
<form action="setup_addresponse.lasso" method="post">

	<table border="0" cellpadding="1" cellspacing="1" width="491">
		<tr>
			<td colspan="2"><strong>NOTE: </strong>[$svInputRequired] indicates required information.</td>
		</tr>
		<tr>
			<td width="130" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<font color="#FFFFFF"><strong>Forum Title</strong></font>[$svInputRequired]
				</p>
			</td>
			<td width="520" valign="top" bgcolor="[Var:'svPostContentColor']">
				<input type="text" name="SectionTitle" value="[Var:'vSection_Title']" size="36" maxlength="64"> 
			</td>
		</tr>
		<tr>
			<td width="130" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<font color="#FFFFFF"><strong>Description</strong></font>
				</p>
			</td>
			<td width="520" valign="top" bgcolor="[Var:'svPostContentColor']">
		     	 <textarea name="SectionDescription" cols="30" rows="4">[Var:'vSection_Description']</textarea>
			</td>
		</tr>
		<tr>
			<td width="130" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<font color="#FFFFFF"><strong>Request Info</strong></font>[$svInputRequired]
				</p>
			</td>
			<td width="520" valign="top" bgcolor="[Var:'svPostContentColor']">
				<select name="RequestInfo"> 
					<option value="" [if: (var:'vRequest_Info') == ''] selected[/If]></option>
					<option value="Y" [if: (var:'vRequest_Info') == 'Y'] selected[/if]>Yes</option>
					<option value="N" [if: (var:'vRequest_Info') == 'N'] selected[/if]>No
					</option>
				</select> 
			</td>
		</tr>
		<tr>
			<td width="130" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<font color="#FFFFFF"><strong>Allow</strong></font>[$svInputRequired]
				</p>
			</td>
			<td width="520" valign="top" bgcolor="[Var:'svPostContentColor']">
				<select name="Allow"> 
					<option value="" [if: (var:'vAllow') == ''] selected[/If]></option>
					<option value="Y" [if: (var:'vAllow') == 'Y'] selected[/if]>Yes</option>
					<option value="N" [if: (var:'vAllow') == 'N'] selected[/if]>No
					</option>
				</select> 
			</td>
		</tr>
			<tr>
				<td colspan="2" bgcolor="[Var:'svTopicHeaderColor']">
					<div align="center">
<?Lassoscript
// If Edit page, add a hidden field to show check if page is submit
// Also add a hidden field with the User_ID
If: (Response_Filepath) >> 'setup_editrecord.lasso';
				'\t\t\t\t<input type="hidden" name="Process" value="Y">\n';
				'\t\t\t\t<input type="hidden" name="SID" value="'($vSID)'">\n';
				'\t\t\t\t<input type="hidden" name="DataType" value="Forum">\n';
				'\t\t\t\t<input type="submit" name="Action" value="Update">\n';
Else;
				'\t\t\t\t<input type="hidden" name="DataType" value="Forum">\n';
				'\t\t\t\t<input type="submit" name="Action" value="Add">\n';
/If; ?>				</div>
			</td>
		</tr>
	</table>
</form>
